﻿<UserControl x:Class="ttg_internal.Utilities.UsageVisualizer.Other.Controls.BarGraph"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:convert="clr-namespace:ttg_internal.Utilities.UsageVisualizer.Converter"
    xmlns:custControls="clr-namespace:ttg_internal.Utilities.UsageVisualizer.Other.Controls"
    x:Name="BarGraphControl" Foreground="LimeGreen">
    
    <StackPanel>
        <StackPanel.Resources>
            <convert:MultiplyConverter x:Key="MultiplyConverter" />
        </StackPanel.Resources>
        
        <Viewport3D x:Name="CpuPumpAnimation3dViewPort" Height="75" Width="75" Margin="0,0,0,-5.00000000000003" Grid.Column="1">
            <Viewport3D.Resources>
                <custControls:Cylinder x:Key="CylinderFactory" />
            </Viewport3D.Resources>
            <Viewport3D.Camera>
                <OrthographicCamera Width="2.5" UpDirection="0,1,0" Position="0.0,-0.2,-5.0" LookDirection="0,0.05,1" />
            </Viewport3D.Camera>
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <Model3DGroup>
                        <DirectionalLight Color="White" Direction="-7,-4,-10" />
                    </Model3DGroup>
                </ModelVisual3D.Content>
            </ModelVisual3D>
            <ModelVisual3D>
                <ModelVisual3D.Transform>
                    <ScaleTransform3D x:Name="BarTransform" CenterY="-1" />
                </ModelVisual3D.Transform>
                <ModelVisual3D.Content>
                    <GeometryModel3D Geometry="{Binding Source={StaticResource CylinderFactory}, Path=Mesh, Mode=OneTime}">
                        <GeometryModel3D.Material>
                            <DiffuseMaterial Brush="{Binding ElementName=BarGraphControl, Path=Foreground}" />
                        </GeometryModel3D.Material>
                    </GeometryModel3D>
                </ModelVisual3D.Content>
            </ModelVisual3D>
        </Viewport3D>
        
        <TextBlock FontSize="14" FontWeight="Bold" Foreground="{Binding ElementName=BarGraphControl, Path=Foreground}"
                   Opacity="1" TextAlignment="Center" Grid.Column="0"
                   Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Path=Percentage,
                   Converter={StaticResource MultiplyConverter}, ConverterParameter=100, StringFormat=\{0:F0\}%}" />
    </StackPanel>
</UserControl>
